import Vue from 'vue'
import VueRouter from 'vue-router'
// 公共页面
import Login from '../views/Login/Login.vue'
import register from '../views/Register/register.vue'
import adminHome from '../views/Home/adminHome.vue'
import main from '../views/Layout/main.vue'
import deliverHome from '../views/Home/deliverHome.vue'
import forgetPassword from '../views/ForgetPassword/forgetPassword.vue'

// 超级管理员
import networkDay from '../views/NetworkDay/networkDay.vue'
import brancheManage from '../views/BrancheManage/brancheManage.vue'
import personnelManage from '../views/PersonnelManage/personnelManage.vue'
import userManage from '../views/PersonnelManage/userManage.vue'


// 网点管理员
import deliverymanManage from '../views/PersonnelManage/deliverymanManage.vue'
import expressManage from '../views/ExpressManage/expressManage.vue'
import expressDelivery from '../views/ExpressManage/expressDelivery.vue'

// 用户
import address from '../views/Address/address.vue'
import mailreceive from '../views/MailReceive/mailreceive.vue'
import send from '../views/Send/send.vue'

import courier from "../views/Courier/courier";

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
    hidden: true
  },
  {
    path: '/register',
    name: 'register',
    component: register,
    hidden: true
  },
  {
    path: '/forgetPassword',
    name: 'forgetPassword',
    component: forgetPassword,
    hidden: true
  },
  {
    path: '/deliverHome',
    name: 'deliverHome',
    component: deliverHome,
    hidden: true
  },
  {
    path: '/home',
    name: 'Main',
    component: main,
    children: [
      {
        path: '/adminHome',
        name: "Home",
        label: "首页",
        icon: "s-home",
        component: adminHome,
      },

    ]
  },
]

export const asyncRoutes = [
  {
    label: "人员管理",
    icon: "user-solid",
    roles: ['3'],
    children:[
      {
        path: '/personnelManage',
        name: "PersonnelManage",
        label: "系统人员管理",
        icon: "user-solid",
        component: personnelManage,
      },
      {
        path: '/userManage',
        name: "PersonnelManage",
        label: "用户管理",
        icon: "user-solid",
        component: userManage,
      },
    ]
  },
  {
    path: '/networkDay',
    name: "NetworkDay",
    label: "网点路线管理",
    icon: "s-promotion",
    component: networkDay,
    roles: ['3'],
  },
  {
    path: '/brancheManage',
    name: "BrancheManage",
    label: "网点管理",
    icon: "s-platform",
    component: brancheManage,
    roles: ['3'],
  },
  {
    path: '/deliverymanManage',
    name: "PersonnelManage",
    label: "快递员管理",
    icon: "user-solid",
    component: deliverymanManage,
    roles: ['2'],
  },
  {
    path: '/expressManage',
    name: "ExpressManage",
    label: "快递列表",
    icon: "tickets",
    component: expressManage,
    roles: ['2'],
  },
  {
    path: '/expressDelivery',
    name: "ExpressManage",
    label: "快递分派",
    icon: "position",
    component: expressDelivery,
    roles: ['2'],
  },
  {
    path: '/address',
    name: "Address",
    label: "我的地址",
    icon: "s-custom",
    component: address,
    roles: ['0'],
  },
  {
    path: '/send',
    name: "Send",
    label: "寄快递",
    icon: "s-custom",
    component: send,
    roles: ['0'],
  },
  {
    path: '/mailreceive',
    name: "MailReceive",
    label: "我收的",
    icon: "s-custom",
    component: mailreceive,
    roles: ['0'],
  },
  {
    path: '/courier',
    name: "Courier",
    label: "快递员",
    icon: "s-custom",
    component: courier,
    roles: ['1'],
  },
]

const router = new VueRouter({
  routes
})

export default router


